/**
 * 导入记录相关逻辑
 * @type {*}
 */
var pageObj = $('#page');
var pageSize = 50;
var cPage = 1;
var dataList;

//初始化
function init() {
    // page, pageSize
    loadData(cPage);
}

/**
 * 查询列表
 */
function searchList() {
    loadData(cPage);
}

function processPage(data) {
    // 处理分页
    pageObj.children().remove();
    pageObj.append('<div id="create_page_num"></div>');
    pageObj.find("#create_page_num").createPage({
        pageCount: data.pages,
        current: data.pageNum,
        backFn: function (p) {
            loadData(p, pageSize);
        }
    });
}

// 加载分页列表
function loadData(pageNo) {
    $.ajax({
        url: "/manage/import/list",
        type: 'POST',
        data: {
               pageNum: pageNo,
               pageSize: pageSize,
               recordNo: $('#recordNo').val(),
               createTimeStart:$('#createTimeStart').val(),
               createTimeEnd:$('#createTimeEnd').val()
        },
        success: function (data) {
            console.log(data);
            dataList = data.data.list;
            var allDataHtml = "";
            for (var i = 0; i < dataList.length; i++) {
                var cData = dataList[i];
                var cHtml =
                    "<tr data-id=\"" + cData.id + "\" data-no=\"" + cData.no + "\">\n" +
                    "<td>" + cData.id + "</td>\n" +
                    "<td>" + cData.recordNo + "</td>\n" +
                    "<td>" + cData.account + "</td>\n" +
                    "<td>" + cData.createTime + "</td>\n" +
                    "<td>" + cData.status + "</td>\n" +
                    "</tr>";
                allDataHtml += cHtml;
            }
            $("#resultList").html();
            $("#resultList").html(allDataHtml);

            // 处理分页
            cPage = pageNo;
            processPage(data.data);
        }
    });
}


